<!DOCTYPE html>
<html>

<head>
  <title>Quarkus - Configuring Your Application</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/config" />
  <meta property="og:title" content="Quarkus - Configuring Your Application" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/config">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Quarkus - Configuring Your Application</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#solution">Solution</a></li>
<li><a href="#creating-the-maven-project">Creating the Maven project</a></li>
<li><a href="#injecting-configuration-value">Injecting configuration value</a></li>
<li><a href="#create-the-configuration">Create the configuration</a></li>
<li><a href="#update-the-test">Update the test</a></li>
<li><a href="#package-and-run-the-application">Package and run the application</a></li>
<li><a href="#programmatically-access-the-configuration">Programmatically access the configuration</a></li>
<li><a href="#using-configproperties">Using @ConfigProperties</a>
<ul class="sectlevel2">
<li><a href="#additional-notes-on-configproperties">Additional notes on @ConfigProperties</a></li>
<li><a href="#using-same-configproperties-with-different-prefixes">Using same ConfigProperties with different prefixes</a></li>
</ul>
</li>
<li><a href="#configuring-quarkus">Configuring Quarkus</a>
<ul class="sectlevel2">
<li><a href="#list-of-all-configuration-properties">List of all configuration properties</a></li>
<li><a href="#generating-configuration-for-your-application">Generating configuration for your application</a></li>
</ul>
</li>
<li><a href="#overriding-properties-at-runtime">Overriding properties at runtime</a>
<ul class="sectlevel2">
<li><a href="#configuration-profiles">Configuration Profiles</a></li>
<li><a href="#using-property-expressions">Using Property Expressions</a></li>
<li><a href="#combining-property-expressions-and-environment-variables">Combining Property Expressions and Environment Variables</a></li>
<li><a href="#clearing-properties">Clearing properties</a></li>
</ul>
</li>
<li><a href="#custom-configuration">Custom Configuration</a>
<ul class="sectlevel2">
<li><a href="#custom-configuration-sources">Custom configuration sources</a></li>
<li><a href="#custom-configuration-converters">Custom configuration converters</a></li>
</ul>
</li>
<li><a href="#yaml">YAML for Configuration</a>
<ul class="sectlevel2">
<li><a href="#add-yaml-config-support">Add YAML Config Support</a></li>
<li><a href="#profile-dependent-configuration">Profile dependent configuration</a></li>
<li><a href="#configuration-key-conflicts">Configuration key conflicts</a></li>
</ul>
</li>
<li><a href="#more-info-on-how-to-configure">More info on how to configure</a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Hardcoded values in your code are a <em>no go</em> (even if we all did it at some point ;-)).
In this guide, we learn how to configure your application.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="prerequisites"><a class="anchor" href="#prerequisites"></a>Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To complete this guide, you need:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>between 5 and 10 minutes</p>
</li>
<li>
<p>an IDE</p>
</li>
<li>
<p>JDK 1.8+ installed with <code>JAVA_HOME</code> configured appropriately</p>
</li>
<li>
<p>Apache Maven 3.6.2+</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="solution"><a class="anchor" href="#solution"></a>Solution</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We recommend that you follow the instructions in the next sections and create the application step by step.
However, you can go right to the completed example.</p>
</div>
<div class="paragraph">
<p>Clone the Git repository: <code>git clone <a href="https://github.com/quarkusio/quarkus-quickstarts.git" class="bare">https://github.com/quarkusio/quarkus-quickstarts.git</a></code>, or download an <a href="https://github.com/quarkusio/quarkus-quickstarts/archive/master.zip">archive</a>.</p>
</div>
<div class="paragraph">
<p>The solution is located in the <code>config-quickstart</code> <a href="https://github.com/quarkusio/quarkus-quickstarts/tree/master/config-quickstart">directory</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="creating-the-maven-project"><a class="anchor" href="#creating-the-maven-project"></a>Creating the Maven project</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First, we need a new project. Create a new project with the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">mvn io.quarkus:quarkus-maven-plugin:1.7.0.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=config-quickstart \
    -DclassName="org.acme.config.GreetingResource" \
    -Dpath="/greeting"
cd config-quickstart</code></pre>
</div>
</div>
<div class="paragraph">
<p>It generates:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the Maven structure</p>
</li>
<li>
<p>a landing page accessible on <code><a href="http://localhost:8080" class="bare">http://localhost:8080</a></code></p>
</li>
<li>
<p>example <code>Dockerfile</code> files for both <code>native</code> and <code>jvm</code> modes</p>
</li>
<li>
<p>the application configuration file</p>
</li>
<li>
<p>an <code>org.acme.config.GreetingResource</code> resource</p>
</li>
<li>
<p>an associated test</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="injecting-configuration-value"><a class="anchor" href="#injecting-configuration-value"></a>Injecting configuration value</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus uses <a href="https://microprofile.io/project/eclipse/microprofile-config">MicroProfile Config</a> to inject the configuration in the application.
The injection uses the <code>@ConfigProperty</code> annotation.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ConfigProperty(name = "greeting.message")
String message;</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
When injecting a configured value, you can use <code>@Inject @ConfigProperty</code> or just <code>@ConfigProperty</code>.
The <code>@Inject</code> annotation is not necessary for members annotated with <code>@ConfigProperty</code>, a behavior which differs from <a href="https://microprofile.io/project/eclipse/microprofile-config">MicroProfile Config</a>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Edit the <code>org.acme.config.GreetingResource</code>, and introduce the following configuration properties:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ConfigProperty(name = "greeting.message") <i class="conum" data-value="1"></i><b>(1)</b>
String message;

@ConfigProperty(name = "greeting.suffix", defaultValue="!") <i class="conum" data-value="2"></i><b>(2)</b>
String suffix;

@ConfigProperty(name = "greeting.name")
Optional&lt;String&gt; name; <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>If you do not provide a value for this property, the application startup fails with <code>javax.enterprise.inject.spi.DeploymentException: No config value of type [class java.lang.String] exists for: greeting.message</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The default value is injected if the configuration does not provide a value for <code>greeting.suffix</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>This property is optional - an empty <code>Optional</code> is injected if the configuration does not provide a value for <code>greeting.name</code>.</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Now, modify the <code>hello</code> method to use the injected properties:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
    return message + " " + name.orElse("world") + suffix;
}</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="create-the-configuration"><a class="anchor" href="#create-the-configuration"></a>Create the configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>By default, Quarkus reads <code>application.properties</code>.
Edit the <code>src/main/resources/application.properties</code> with the following content:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs"># Your configuration properties
greeting.message = hello
greeting.name = quarkus</code></pre>
</div>
</div>
<div class="paragraph">
<p>Once set, check the application with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ curl http://localhost:8080/greeting
hello quarkus!</code></pre>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
If the application requires configuration values and these values are not set, an error is thrown.
So you can quickly know when your configuration is complete.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="update-the-test"><a class="anchor" href="#update-the-test"></a>Update the test</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We also need to update the functional test to reflect the changes made to the endpoint.
Edit the <code>src/test/java/org/acme/config/GreetingResourceTest.java</code> file and change the content of the <code>testHelloEndpoint</code> method to:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.config;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

@QuarkusTest
public class GreetingResourceTest {

    @Test
    public void testHelloEndpoint() {
        given()
          .when().get("/greeting")
          .then()
             .statusCode(200)
             .body(is("hello quarkus!")); // Modified line
    }

}</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="package-and-run-the-application"><a class="anchor" href="#package-and-run-the-application"></a>Package and run the application</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Run the application with: <code>./mvnw compile quarkus:dev</code>.
Open your browser to <a href="http://localhost:8080/greeting" class="bare">http://localhost:8080/greeting</a>.</p>
</div>
<div class="paragraph">
<p>Changing the configuration file is immediately reflected.
You can add the <code>greeting.suffix</code>, remove the other properties, change the values, etc.</p>
</div>
<div class="paragraph">
<p>As usual, the application can be packaged using <code>./mvnw clean package</code> and executed using the <code>-runner.jar</code> file.
You can also generate the native executable with <code>./mvnw clean package -Pnative</code>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="programmatically-access-the-configuration"><a class="anchor" href="#programmatically-access-the-configuration"></a>Programmatically access the configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can access the configuration programmatically.
It can be handy to achieve dynamic lookup, or retrieve configured values from classes that are neither CDI beans or JAX-RS resources.</p>
</div>
<div class="paragraph">
<p>You can access the configuration programmatically using <code>org.eclipse.microprofile.config.ConfigProvider.getConfig()</code> such as in:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">String databaseName = ConfigProvider.getConfig().getValue("database.name", String.class);
Optional&lt;String&gt; maybeDatabaseName = ConfigProvider.getConfig().getOptionalValue("database.name", String.class);</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="using-configproperties"><a class="anchor" href="#using-configproperties"></a>Using @ConfigProperties</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As an alternative to injecting multiple related configuration values in the way that was shown in the previous example,
users can also use the <code>@io.quarkus.arc.config.ConfigProperties</code> annotation to group these properties together.</p>
</div>
<div class="paragraph">
<p>For the greeting properties above, a <code>GreetingConfiguration</code> class could be created like so:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.config;

import io.quarkus.arc.config.ConfigProperties;
import java.util.Optional;

@ConfigProperties(prefix = "greeting") <i class="conum" data-value="1"></i><b>(1)</b>
public class GreetingConfiguration {

    private String message;
    private String suffix = "!"; <i class="conum" data-value="2"></i><b>(2)</b>
    private Optional&lt;String&gt; name;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public Optional&lt;String&gt; getName() {
        return name;
    }

    public void setName(Optional&lt;String&gt; name) {
        this.name = name;
    }
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td><code>prefix</code> is optional. If not set then the prefix to be used will be determined by the class name. In this case it would still be <code>greeting</code> (since the <code>Configuration</code> suffix is removed). If the class were named <code>GreetingExtraConfiguration</code> then the resulting default prefix would be <code>greeting-extra</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td><code>!</code> will be the default value if <code>greeting.suffix</code> is not set</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>This class could then be injected into the <code>GreetingResource</code> using the familiar CDI <code>@Inject</code> annotation like so:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@Inject
GreetingConfiguration greetingConfiguration;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Another alternative style provided by Quarkus is to create <code>GreetingConfiguration</code> as an interface like so:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.config;

import io.quarkus.arc.config.ConfigProperties;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import java.util.Optional;

@ConfigProperties(prefix = "greeting")
public interface GreetingConfiguration {

    @ConfigProperty(name = "message") <i class="conum" data-value="1"></i><b>(1)</b>
    String message();

    @ConfigProperty(defaultValue = "!")
    String getSuffix(); <i class="conum" data-value="2"></i><b>(2)</b>

    Optional&lt;String&gt; getName(); <i class="conum" data-value="3"></i><b>(3)</b>
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The <code>@ConfigProperty</code> annotation is needed because the name of the configuration property that the method corresponds to doesn&#8217;t follow the getter method naming conventions</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>In this case since <code>name</code> was not set, the corresponding property will be <code>greeting.suffix</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>It is unnecessary to specify the <code>@ConfigProperty</code> annotation because the method name follows the getter method naming conventions (<code>greeting.name</code> being the corresponding property) and no default value is needed.</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>When using <code>@ConfigProperties</code> on a class or an interface, if the value of one of its fields is not provided, the application startup will fail and a <code>javax.enterprise.inject.spi.DeploymentException</code> indicating the missing value information will be thrown.
This does not apply to <code>Optional</code> fields and fields with a default value.</p>
</div>
<div class="sect2">
<h3 id="additional-notes-on-configproperties"><a class="anchor" href="#additional-notes-on-configproperties"></a>Additional notes on @ConfigProperties</h3>
<div class="paragraph">
<p>When using a regular class annotated with <code>@ConfigProperties</code> the class doesn&#8217;t necessarily have to declare getters and setters.
Having simple public non-final fields is valid as well.</p>
</div>
<div class="paragraph">
<p>Furthermore, the configuration classes support nested object configuration. Suppose there was a need to have an extra layer
of greeting configuration named <code>hidden</code> that would contain a few fields. This could be achieved like so:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ConfigProperties(prefix = "greeting")
public class GreetingConfiguration {

    public String message;
    public String suffix = "!";
    public Optional&lt;String&gt; name;
    public HiddenConfig hidden; <i class="conum" data-value="1"></i><b>(1)</b>

    public static class HiddenConfig {
        public Integer prizeAmount;
        public List&lt;String&gt; recipients;
    }
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The name of the field (not the class name) will determine the name of the properties that are bound to the object.</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Setting the properties would occur in the normal manner, for example in <code>application.properties</code> one could have:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">greeting.message = hello
greeting.name = quarkus
greeting.hidden.prize-amount=10
greeting.hidden.recipients=Jane,John</code></pre>
</div>
</div>
<div class="paragraph">
<p>Furthermore, classes annotated with <code>@ConfigProperties</code> can be annotated with Bean Validation annotations similar to the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ConfigProperties(prefix = "greeting")
public class GreetingConfiguration {

    @Size(min = 20)
    public String message;
    public String suffix = "!";

}</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
For validation to work, the <code>quarkus-hibernate-validator</code> extension needs to be present.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>If the validation fails with the given configuration, the application will fail to start and indicate the corresponding validation errors in the log.</p>
</div>
<div class="paragraph">
<p>In the case of an interface being annotated with <code>@ConfigProperties</code>, the interface is allowed to extend other interfaces and methods from
the entire interface hierarchy are used to bind properties.</p>
</div>
</div>
<div class="sect2">
<h3 id="using-same-configproperties-with-different-prefixes"><a class="anchor" href="#using-same-configproperties-with-different-prefixes"></a>Using same ConfigProperties with different prefixes</h3>
<div class="paragraph">
<p>Quarkus also supports the use of the same <code>@ConfigProperties</code> object with different prefixes for each injection point using the <code>io.quarkus.arc.config.@ConfigPrefix</code> annotation.
Say for example that <code>GreetingConfiguration</code> from above needs to be used for both the <code>greeting</code> prefix and the <code>other</code> prefix.
In that case the code would look like so:</p>
</div>
<div class="paragraph">
<p><code>GreetingConfiguration.java</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ConfigProperties(prefix = "greeting")
public class GreetingConfiguration {

    @Size(min = 20)
    public String message;
    public String suffix = "!";

}</code></pre>
</div>
</div>
<div class="paragraph">
<p><code>SomeBean.java</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ApplicationScoped
public class SomeBean {

    @Inject <i class="conum" data-value="1"></i><b>(1)</b>
    GreetingConfiguration greetingConfiguration;

    @ConfigPrefix("other") <i class="conum" data-value="2"></i><b>(2)</b>
    GreetingConfiguration otherConfiguration;

}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>At this injection point <code>greetingConfiguration</code> will use the <code>greeting</code> prefix since that is what has been defined on <code>@ConfigProperties</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>At this injection point <code>otherConfiguration</code> will use the <code>other</code> prefix from <code>@ConfigPrefix</code> instead of the <code>greeting</code> prefix. Notice that in this case <code>@Inject</code> is not required.</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="configuring-quarkus"><a class="anchor" href="#configuring-quarkus"></a>Configuring Quarkus</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus itself is configured via the same mechanism as your application. Quarkus reserves the <code>quarkus.</code> namespace
for its own configuration. For example to configure the HTTP server port you can set <code>quarkus.http.port</code> in
<code>application.properties</code>.</p>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<div class="paragraph">
<p>As mentioned above, properties prefixed with <code>quarkus.</code> are effectively reserved for configuring Quarkus itself and
therefore <code>quarkus.</code> should <strong>never</strong> be used as prefix for application specific properties.</p>
</div>
<div class="paragraph">
<p>In the previous examples using <code>quarkus.message</code> instead of <code>greeting.message</code> would result in unexpected behavior.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect2">
<h3 id="list-of-all-configuration-properties"><a class="anchor" href="#list-of-all-configuration-properties"></a>List of all configuration properties</h3>
<div class="paragraph">
<p>All the Quarkus configuration properties are <a href="all-config">documented and searcheable</a>.</p>
</div>
</div>
<div class="sect2">
<h3 id="generating-configuration-for-your-application"><a class="anchor" href="#generating-configuration-for-your-application"></a>Generating configuration for your application</h3>
<div class="paragraph">
<p>It is also possible to generate an example <code>application.properties</code> with all known configuration properties, to make
it easy to see what Quarkus configuration options are available. To do this, run:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./mvnw quarkus:generate-config</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will create a <code>src/main/resources/application.properties.example</code> file that contains all the config options
exposed via the extensions you currently have installed. These options are commented out, and have their default value
when applicable. For example this HTTP port config entry will appear as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">#
# The HTTP port
#
#quarkus.http.port=8080</code></pre>
</div>
</div>
<div class="paragraph">
<p>Rather than generating an example config file, you can also add these to you actual config file by setting the <code>-Dfile</code>
parameter:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./mvnw quarkus:generate-config -Dfile=application.properties</code></pre>
</div>
</div>
<div class="paragraph">
<p>If a config option is already present (commented or not) it will not be added, so it is safe to run this after
adding an additional extension to see what additional options have been added.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="overriding-properties-at-runtime"><a class="anchor" href="#overriding-properties-at-runtime"></a>Overriding properties at runtime</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus does much of its configuration and bootstrap at build time.
Most properties will then be read and set during the build time step.
To change them, make sure to repackage your application.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./mvnw clean package</code></pre>
</div>
</div>
<div class="paragraph">
<p>Extensions do define <em>some</em> properties as overridable at runtime.
A canonical example is the database URL, username and password which is only known specifically in your target environment.
This is a tradeoff as the more runtime properties are available, the less build time prework Quarkus can do. The list of runtime properties is therefore lean.</p>
</div>
<div class="paragraph">
<p>You can override these runtime properties with the following mechanisms (in decreasing priority):</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>using system properties:</p>
<div class="ulist">
<ul>
<li>
<p>for a runner jar: <code>java -Dquarkus.datasource.password=youshallnotpass -jar target/myapp-runner.jar</code></p>
</li>
<li>
<p>for a native executable: <code>./target/myapp-runner -Dquarkus.datasource.password=youshallnotpass</code></p>
</li>
</ul>
</div>
</li>
<li>
<p>using environment variables:</p>
<div class="ulist">
<ul>
<li>
<p>for a runner jar: <code>export QUARKUS_DATASOURCE_PASSWORD=youshallnotpass ; java -jar target/myapp-runner.jar</code></p>
</li>
<li>
<p>for a native executable: <code>export QUARKUS_DATASOURCE_PASSWORD=youshallnotpass ; ./target/myapp-runner</code></p>
</li>
</ul>
</div>
</li>
<li>
<p>using an environment file named <code>.env</code> placed in the current working directory containing the line <code>QUARKUS_DATASOURCE_PASSWORD=youshallnotpass</code> (for dev mode, this file can be placed in the root of the project, but it is advised to not check it in to version control)</p>
</li>
<li>
<p>using a configuration file placed in <code>$PWD/config/application.properties</code></p>
<div class="ulist">
<ul>
<li>
<p>By placing an <code>application.properties</code> file inside a directory named <code>config</code> which resides in the directory where the application runs, any runtime properties defined
in that file will override the default configuration. Furthermore any runtime properties added to this file that were not part of the original <code>application.properties</code> file
<em>will also</em> be taken into account.</p>
</li>
<li>
<p>This works in the same way for runner jar and the native executable</p>
</li>
</ul>
</div>
</li>
</ol>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Environment variables names are following the conversion rules of <a href="https://github.com/eclipse/microprofile-config/blob/master/spec/src/main/asciidoc/configsources.asciidoc#default-configsources">Eclipse MicroProfile</a>
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The <code>config/application.properties</code> features is available in development mode as well. To make use of it, <code>config/application.properties</code> needs to be placed inside the build tool&#8217;s output directory (<code>target</code> for Maven and <code>build/classes/java/main</code> for Gradle).
Keep in mind however that any cleaning operation from the build tool like <code>mvn clean</code> or <code>gradle clean</code> will remove the <code>config</code> directory as well.
</td>
</tr>
</table>
</div>
<div class="sect2">
<h3 id="configuration-profiles"><a class="anchor" href="#configuration-profiles"></a>Configuration Profiles</h3>
<div class="paragraph">
<p>Quarkus supports the notion of configuration profiles. These allow you to have multiple configuration in the same file and
select between them via a profile name.</p>
</div>
<div class="paragraph">
<p>The syntax for this is <code>%{profile}.config.key=value</code>. For example if I have the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">quarkus.http.port=9090
%dev.quarkus.http.port=8181</code></pre>
</div>
</div>
<div class="paragraph">
<p>The Quarkus HTTP port will be 9090, unless the <code>dev</code> profile is active, in which case it will be 8181.</p>
</div>
<div class="paragraph">
<p>By default Quarkus has three profiles, although it is possible to use as many as you like. The default profiles are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>dev</strong> - Activated when in development mode (i.e. <code>quarkus:dev</code>)</p>
</li>
<li>
<p><strong>test</strong> - Activated when running tests</p>
</li>
<li>
<p><strong>prod</strong> - The default profile when not running in development or test mode</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>There are two ways to set a custom profile, either via the <code>quarkus.profile</code> system property or the <code>QUARKUS_PROFILE</code>
environment variable. If both are set the system property takes precedence. Note that it is not necessary to
define the names of these profiles anywhere, all that is necessary is to create a config property with the profile
name, and then set the current profile to that name. For example if I want a <code>staging</code> profile with a different HTTP port
I can add the following to <code>application.properties</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">quarkus.http.port=9090
%staging.quarkus.http.port=9999</code></pre>
</div>
</div>
<div class="paragraph">
<p>And then set the <code>QUARKUS_PROFILE</code> environment variable to <code>staging</code> to activate my profile.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The proper way to check the active profile programmatically is to use the <code>getActiveProfile</code> method of <code>io.quarkus.runtime.configuration.ProfileManager</code>.</p>
</div>
<div class="paragraph">
<p>Using <code>@ConfigProperty("quarkus.profile")</code> will <strong>not</strong> work properly.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="using-property-expressions"><a class="anchor" href="#using-property-expressions"></a>Using Property Expressions</h3>
<div class="paragraph">
<p>Quarkus supports the use of property expressions in the <code>application.properties</code> file.</p>
</div>
<div class="paragraph">
<p>These expressions are resolved when the property is read.
So if your configuration property is a build time configuration property, the property expression will be resolved at build time.
If your configuration property is overridable at runtime, the property expression will be resolved at runtime.</p>
</div>
<div class="paragraph">
<p>You can use property expressions both for the Quarkus configuration or for your own configuration properties.</p>
</div>
<div class="paragraph">
<p>Property expressions are defined this way: <code>${my-property-expression}</code>.</p>
</div>
<div class="paragraph">
<p>For example, having the following property:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">remote.host=quarkus.io</code></pre>
</div>
</div>
<div class="paragraph">
<p>and another property defined as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">callable.url=https://${remote.host}/</code></pre>
</div>
</div>
<div class="paragraph">
<p>will result in the value of the <code>callable.url</code> property being set to:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">callable.url=https://quarkus.io/</code></pre>
</div>
</div>
<div class="paragraph">
<p>Another example would be defining different database servers depending on the profile used:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">%dev.quarkus.datasource.url=jdbc:mysql://localhost:3306/mydatabase?useSSL=false
quarkus.datasource.url=jdbc:mysql://remotehost:3306/mydatabase?useSSL=false</code></pre>
</div>
</div>
<div class="paragraph">
<p>can be simplified by having:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">%dev.application.server=localhost
application.server=remotehost

quarkus.datasource.url=jdbc:mysql://${application.server}:3306/mydatabase?useSSL=false</code></pre>
</div>
</div>
<div class="paragraph">
<p>It does result in one more line in this example but the value of <code>application.server</code> can be reused in other properties,
diminishing the possibility of typos and providing more flexibility in property definitions.</p>
</div>
</div>
<div class="sect2">
<h3 id="combining-property-expressions-and-environment-variables"><a class="anchor" href="#combining-property-expressions-and-environment-variables"></a>Combining Property Expressions and Environment Variables</h3>
<div class="paragraph">
<p>Quarkus also supports the combination of both property expressions and environment variables.</p>
</div>
<div class="paragraph">
<p>Let&#8217;s assume you have following property defined in <code>application.properties</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">remote.host=quarkus.io</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can combine environment variables and property expressions by having a property defined as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">application.host=${HOST:${remote.host}}</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will expand the <code>HOST</code> environment variable and use the value of the property <code>remote.host</code> as the default value if <code>HOST</code> is not set.</p>
</div>
<div class="paragraph">
<p>For the purpose of this section we used the property <code>remote.host</code> we defined previously.
It has to be noted that the value could have been a fixed one such as in:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">application.host=${HOST:localhost}</code></pre>
</div>
</div>
<div class="paragraph">
<p>which will result in <code>localhost</code> as the default value if <code>HOST</code> is not set.</p>
</div>
</div>
<div class="sect2">
<h3 id="clearing-properties"><a class="anchor" href="#clearing-properties"></a>Clearing properties</h3>
<div class="paragraph">
<p>Run time properties which are optional, and which have had values set at build time or which have a default value,
may be explicitly cleared by assigning an empty string to the property.  Note that this will <em>only</em> affect
run time properties, and will <em>only</em> work with properties whose values are not required.</p>
</div>
<div class="paragraph">
<p>The property may be cleared by setting the corresponding <code>application.properties</code> property, setting the
corresponding system property, or setting the corresponding environment variable.</p>
</div>
<div class="sect3">
<h4 id="miscellaneous"><a class="anchor" href="#miscellaneous"></a>Miscellaneous</h4>
<div class="paragraph">
<p>The default Quarkus application runtime profile is set to the profile used to build the application.
For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./mvnw package -Pnative -Dquarkus.profile=prod-aws
./target/my-app-1.0-runner <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The command will run with the <code>prod-aws</code> profile. This can be overridden using the <code>quarkus.profile</code> system property.</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="custom-configuration"><a class="anchor" href="#custom-configuration"></a>Custom Configuration</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="custom-configuration-sources"><a class="anchor" href="#custom-configuration-sources"></a>Custom configuration sources</h3>
<div class="paragraph">
<p>You can also introduce custom configuration sources in the standard MicroProfile Config manner.  To
do this, you must provide a class which implements either <code>org.eclipse.microprofile.config.spi.ConfigSource</code>
or <code>org.eclipse.microprofile.config.spi.ConfigSourceProvider</code>.  Create a
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html">service file</a> for the
class and it will be detected and installed at application startup.</p>
</div>
</div>
<div class="sect2">
<h3 id="custom-configuration-converters"><a class="anchor" href="#custom-configuration-converters"></a>Custom configuration converters</h3>
<div class="paragraph">
<p>You can also use your custom types as a configuration values. This can be done by implementing <code>org.eclipse.microprofile.config.spi.Converter&lt;T&gt;</code>
and adding its fully qualified class name in the <code>META-INF/services/org.eclipse.microprofile.config.spi.Converter</code> file.</p>
</div>
<div class="paragraph">
<p>Let us assume you have a custom type like this one:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.config;

public class MicroProfileCustomValue {

    private final int number;

    public MicroProfileCustomValue(int number) {
        this.number = number;
    };

    public int getNumber() {
        return number;
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The corresponding converter will look like the one below. Please note that your custom converter class must be <code>public</code> and must have
a <code>public</code> no-argument constructor. It also must not be <code>abstract</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.config;

import org.eclipse.microprofile.config.spi.Converter;

public class MicroProfileCustomValueConverter implements Converter&lt;MicroProfileCustomValue&gt; {

    @Override
    public MicroProfileCustomValue convert(String value) {
        return new MicroProfileCustomValue(Integer.valueOf(value));
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then you need to include the fully qualified class name of the converter in a service file <code>META-INF/services/org.eclipse.microprofile.config.spi.Converter</code>.
If you have more converters, simply add their class names in this file as well. Single fully qualified class name per line, for example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">org.acme.config.MicroProfileCustomValueConverter
org.acme.config.SomeOtherConverter
org.acme.config.YetAnotherConverter</code></pre>
</div>
</div>
<div class="paragraph">
<p>Please note that <code>SomeOtherConverter</code> and <code>YetAnotherConverter</code> were added just for a demonstration. If you include in this file classes
which are not available at runtime, the converters loading will fail.</p>
</div>
<div class="paragraph">
<p>After this is done you can use your custom type as a configuration value:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ConfigProperty(name = "configuration.value.name")
MicroProfileCustomValue value;</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="converter-priority"><a class="anchor" href="#converter-priority"></a>Converter priority</h4>
<div class="paragraph">
<p>In some cases, you may want to use a custom converter to convert a type which is already converted
by a different converter. In such cases, you can use the <code>javax.annotation.Priority</code> annotation to
change converters precedence and make your custom converter of higher priority than the other
on the list.</p>
</div>
<div class="paragraph">
<p>By default, if no <code>@Priority</code> can be found on a converter, it&#8217;s registered with a priority of 100
and all Quarkus core converters are registered with a priority of 200, so depending on which
converter you would like to replace, you need to set a higher value.</p>
</div>
<div class="paragraph">
<p>To demonstrate the idea let us implement a custom converter which will take precedence over
<code>MicroProfileCustomValueConverter</code> implemented in the previous example.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">package org.acme.config;

import javax.annotation.Priority;
import org.eclipse.microprofile.config.spi.Converter;

@Priority(150)
public class MyCustomConverter implements Converter&lt;MicroProfileCustomValue&gt; {

    @Override
    public MicroProfileCustomValue convert(String value) {

        final int secretNumber;
        if (value.startsFrom("OBF:")) {
            secretNumber = Integer.valueOf(SecretDecoder.decode(value));
        } else {
            secretNumber = Integer.valueOf(value);
        }

        return new MicroProfileCustomValue(secretNumber);
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Since it converts the same value type (namely <code>MicroProfileCustomValue</code>) and has a priority
of 150, it will be used instead of a <code>MicroProfileCustomValueConverter</code> which has a default
priority of 100.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This new converter also needs to be listed in a service file, i.e. <code>META-INF/services/org.eclipse.microprofile.config.spi.Converter</code>.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="yaml"><a class="anchor" href="#yaml"></a>YAML for Configuration</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="add-yaml-config-support"><a class="anchor" href="#add-yaml-config-support"></a>Add YAML Config Support</h3>
<div class="paragraph">
<p>You might want to use YAML over properties for configuration.
Since <a href="https://github.com/smallrye/smallrye-config">SmallRye Config</a> brings support for YAML
configuration, Quarkus supports this as well.</p>
</div>
<div class="paragraph">
<p>First you will need to add the YAML extension to your <code>pom.xml</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="xml" class="language-xml hljs">&lt;dependency&gt;
    &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
    &lt;artifactId&gt;quarkus-config-yaml&lt;/artifactId&gt;
&lt;/dependency&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Or you can alternatively run this command in the directory containing your Quarkus project:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="bash" class="language-bash hljs">./mvnw quarkus:add-extension -Dextensions="config-yaml"</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now Quarkus can read YAML configuration files.
The config directories and priorities are the same as before.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Quarkus will choose an <code>application.yaml</code> over an <code>application.properties</code>.
YAML files are just an alternative way to configure your application.
You should decide and keep one configuration type to avoid errors.
</td>
</tr>
</table>
</div>
<div class="sect3">
<h4 id="configuration-examples"><a class="anchor" href="#configuration-examples"></a>Configuration Examples</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="yaml" class="language-yaml hljs"># YAML supports comments
quarkus:
  datasource:
    url: jdbc:postgresql://localhost:5432/some-database
    driver: org.postgresql.Driver
    username: quarkus
    password: quarkus

# REST Client configuration property
org:
  acme:
    restclient:
      CountriesService/mp-rest/url: https://restcountries.eu/rest

# For configuration property names that use quotes, do not split the string inside the quotes.
quarkus:
  log:
    category:
      "io.quarkus.category":
        level: INFO</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Quarkus also supports using <code>application.yml</code> as the name of the YAML file. The same rules apply for this file as for <code>application.yaml</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="profile-dependent-configuration"><a class="anchor" href="#profile-dependent-configuration"></a>Profile dependent configuration</h3>
<div class="paragraph">
<p>Providing profile dependent configuration with YAML is done like with properties.
Just add the <code>%profile</code> wrapped in quotation marks before defining the key-value pairs:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="yaml" class="language-yaml hljs">"%dev":
  quarkus:
    datasource:
      url: jdbc:postgresql://localhost:5432/some-database
      driver: org.postgresql.Driver
      username: quarkus
      password: quarkus</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="configuration-key-conflicts"><a class="anchor" href="#configuration-key-conflicts"></a>Configuration key conflicts</h3>
<div class="paragraph">
<p>The MicroProfile Configuration specification defines configuration keys as an arbitrary <code>.</code>-delimited string.
However, structured formats like YAML naively only support a subset of the possible configuration namespace.
For example, consider the two configuration properties <code>quarkus.http.cors</code> and <code>quarkus.http.cors.methods</code>.
One property is the prefix of another, so it may not be immediately evident how to specify both keys in your YAML configuration.</p>
</div>
<div class="paragraph">
<p>This is solved by using a null key (normally represented by <code>~</code>) for any YAML property which is a prefix of another one.  Here&#8217;s an example:</p>
</div>
<div class="listingblock">
<div class="title">An example YAML configuration resolving prefix-related key name conflicts</div>
<div class="content">
<pre class="highlightjs highlight"><code data-lang="yaml" class="language-yaml hljs">quarkus:
  http:
    cors:
      ~: true
      methods: GET,PUT,POST</code></pre>
</div>
</div>
<div class="paragraph">
<p>In general, null YAML keys are not included in assembly of the configuration property name, allowing them to be used to
any level for disambiguating configuration keys.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="more-info-on-how-to-configure"><a class="anchor" href="#more-info-on-how-to-configure"></a>More info on how to configure</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus relies on SmallRye Config and inherits its features.</p>
</div>
<div class="paragraph">
<p>SmallRye Config provides:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Additional Config Sources</p>
</li>
<li>
<p>Additional Converters</p>
</li>
<li>
<p>Interceptors for configuration value resolution</p>
</li>
<li>
<p>Relocate Configuration Properties</p>
</li>
<li>
<p>Fallback Configuration Properties</p>
</li>
<li>
<p>Logging</p>
</li>
<li>
<p>Hide Secrets</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For more information, please check the
<a href="https://smallrye.io/docs/smallrye-config/index.html">SmallRye Config documentation</a>.</p>
</div>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
